It is not being used, and implementing it efficiently is infeasible without
reducing the efficiency of cases that matter more.
Change-Id: Ie53250f0e63ad08a418724c60a74a52edbdfdb29
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226358
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This has the exporter registered but doing nothing, to measure the basic cost of
having any exporter without any specific exporter costs.
Specifically at the moment this measures the cost of filling in the time on the
event and building the TagMap that is passed down.
Change-Id: Iaae5659e3de9b871dc281c509fa2ee9c3e1d049a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226357
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Some things that used to be safe due to the global
lock now need ther own synchronization primitives.
Fixesgolang/go#38102
Change-Id: I03c692682d57620d96fe84b7dc74efae0d3f8f09
Reviewed-on: https://go-review.googlesource.com/c/tools/+/226317
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This changes span events to return a cheaper end function if there is
no exporter and also to deliver the end event to the same exporter
that the start even was delivered to rather than which was active
when the end event is triggered.
Change-Id: I831283da20e8cc991a0cf7490952ae194d125428
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225737
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Type switch on the key and use it to get the value and decide how
to render it.
Use the same render for all debug tag printing.
Change-Id: Ia305fded7dcf05b57c5805f48bb5c22fa7def71f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225380
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This uses the strongly typed key to get the value rather than
type switching on the value itself.
Change-Id: I8f72d1d9cac0191b0565c14d8a1108459ee6df36
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225379
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Now that keys are solidly typed, we can use them for the metrics.
This prevents accidentally using the wrong type of key, and
allows us to use the typed accesorrs rather than the raw value.
Change-Id: I553bd8e12128d3f00a3e926dbd3bfd420cd3f135
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225378
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This changes the benchmarks to be less heavy weight.
It allows the baseline to have no allocations and be
very lightweight. This makes it easier to see
realistic numbers for the costs of the various
operations, making it easier to track and optimize.
Change-Id: I07699881d6976c3ab3432373f057b563752509b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225337
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
There is no reason for it to be public now, it is no longer possible to build an
event
without using the helpers.
This also allows us to delay setting the time until after the nil exporter
check, for
a significant time saving in the no exporter case.
name old time/op new time/op delta
/Baseline-8 588ns ± 4% 575ns ± 4% -2.24% (p=0.000 n=18+18)
/StdLog-8 9.61µs ± 3% 9.58µs ± 3% ~ (p=0.384 n=18+18)
/LogNoExporter-8 3.94µs ± 2% 2.26µs ± 2% -42.50% (p=0.000 n=17+18)
/TraceNoExporter-8 2.77µs ± 4% 1.11µs ± 2% -59.82% (p=0.000 n=18+18)
/StatsNoExporter-8 3.83µs ± 5% 2.15µs ± 3% -43.70% (p=0.000 n=18+17)
/Log-8 23.3µs ± 6% 23.0µs ± 1% ~ (p=0.245 n=18+17)
/Trace-8 26.4µs ± 3% 26.5µs ± 4% ~ (p=0.269 n=18+17)
/Stats-8 5.36µs ± 2% 5.45µs ± 3% +1.68% (p=0.000 n=17+18)
Change-Id: Ibde0e20eaf99d03f786cd1436f05eab7b2a17b20
Reviewed-on: https://go-review.googlesource.com/c/tools/+/224657
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This separates the concerns of tag collections that have to be iterated
and tag collections that need lookup by key.
Also make it so that events just carry a plain slice of tags.
We pass a TagMap down through the exporters and allow it to be
extended on the way.
We no longer need the event.Query method (or the event type)
We now exclusivley use Key as the identity, and no longer have a
common core implementation but just implement it directly in each
type.
This removes some confusion that was causing the same key through
different paths to end up with a different identity.
Change-Id: I61e47adcb397f4ca83dd90342b021dd8e9571ed3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/224278
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This change updates the metrics tutorial to include example code for
exporting traces from go tools.
Change-Id: Ie1d3c373ed4308ef0160f6389b74c642b348bed6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225061
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This change updates the metrics tutorial to be compatible with the new event system.
Change-Id: I8b75f6b02d241bc9dede01cfac167a982f1df67c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/225058
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This allows us to hide the implementation details of how tags are stored on a
context from the normal interface, to allow us to explore more efficient
mechanisms.
The current storage is not intended as the most efficient choice, this cl is
about isolating the API so we can experiment with benchmarks in the future.
Change-Id: Ib101416bccd8ecdee269cee636b1564d51e1da8a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222854
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This change updates the metric exporting tutorial to use oragent to spin
up OpenCensus, Prometheus, and Zipkin all at once using docker-compose
rather than manually setting each one up. This allows developers to set
up an environment for testing metrics and traces with minimal effort.
While oragent also spins up Zipkin for traces, the tutorial does not yet
have a section outlining how to export traces from Go tools. A section
for traces will added in a later CL.
Change-Id: I07f49977f7ab49995853ff8ee8eb6ccdf6ef1642
Reviewed-on: https://go-review.googlesource.com/c/tools/+/224258
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This changes the way keys work, there is still a single internal key
implementation for performance reasons, but the public interface is a set of key
implementations that have type safe Of and Get methods.
This also hides the implemenation of Tag so that we can modify the storage form
and find a more efficient storage if needed.
Change-Id: I6a39cc75c2824c6a92e52d59f16e82e876f16e9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/223137
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
It encourages poor performing log lines, and also reduces the readability of
those lines.
Also delete the Key.With method which was unused, and should never be used
instead of the event.Label function anyway.
Change-Id: I9b55102864ee49a7d03e60af022a2002170c0fb1
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222851
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Rather than building cusom events and driving the exporter, the test now
registers a custom exporter and then uses the normal higher level methods to
deliver events to it.
This means we are testing the actual information that would arise in a user
program, and also means we no longer have to expose internal features just for
tests.
Metrics are not fully converted yet.
Change-Id: I63248a480fb1b3e6274dce0c2e1d66904d055978
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222849
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This allows early exporters to adjust the event for later ones.
This is used to lookup key values from the context if needed.
Also add a Query type event which is intended to perform all event
modifications but nothing else, and is used to lookup values from
the context. This cleans up a weirdness where the current lookup
presumes there will be an exporter with a matching mechanism.
Change-Id: I835d1e0b2511553c30f94b7becfe7b7b5462c111
Reviewed-on: https://go-review.googlesource.com/c/tools/+/223657
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This moves the actual trace test into its own file so that it can easily
be seen separately from the functions that support all tests.
Change-Id: I1d30cf8a712377ca79a5de77b85412c881177f43
Reviewed-on: https://go-review.googlesource.com/c/tools/+/223397
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This makes keys a pointer, which reduces the allocations during logging, and has
a significant improvement in memory and cpu cost when there is no exporter.
Packing a string into an interface requires a 16 byte allocation, packing a pointer
does not.
name old time/op new time/op delta
/LogNoExporter-8 4.39µs ± 2% 3.83µs ± 2% -12.74% (p=0.000 n=18+20)
/Log-8 23.5µs ± 2% 22.6µs ± 1% -4.20% (p=0.000 n=19+18)
name old alloc/op new alloc/op delta
/LogNoExporter-8 1.70kB ± 0% 1.38kB ± 0% -18.78% (p=0.000 n=20+20)
/Log-8 4.91kB ± 0% 4.91kB ± 0% ~ (p=1.000 n=20+20)
name old allocs/op new allocs/op delta
/LogNoExporter-8 83.0 ± 0% 63.0 ± 0% -24.10% (p=0.000 n=20+20)
/Log-8 163 ± 0% 163 ± 0% ~ (all equal)
Change-Id: Iec127f1bff8d5c8f4bd0a6d9f6d8fc4b8bc740b2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222599
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This is now the only package that is exposed to normal use, and should
be the only thing to appear in libraries.
Change-Id: I90ee47c6519f30db16ff5d5d2910be86e91e5df2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222557
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
deliver detach to the exporter as an event rather than hard coding the
span detach behavior.
Change-Id: I87b6e2a3596fea338908c11ba0b219176b6305bf
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222542
Reviewed-by: Robert Findley <rfindley@google.com>
This type was previously guarded implicitly by the global exporter
mutex. With that gone, we've started seeing panics due to races in
(*rpcs).Metric.
Guard it with a mutex.
Change-Id: I2a8c670ecfbaee9422e1f1d282b1fedb86b6a5e0
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222300
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This means that tags also become cheap if there is no exporter and cleans up the
mess with how spans, tags and logs were related.
Also fixes the currently broken metrics that relied on the span tags.
Change-Id: I8e56b6218a60fd31a1f6c8d329dbb2cab1b9254d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/222065
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
We no longer use the span as the core type of tracing, instead that is an
artifact of the exporter, and start and end tracing is just event based.
This both makes the interface normalized, and also means the null exporter case
is considerably cheaper in memory and cpu.
See below for benchstat changes
name old time/op new time/op delta
TracingNoExporter-8 4.19µs ±12% 2.71µs ±11% -35.33% (p=0.000 n=20+20)
Tracing-8 24.1µs ± 3% 5.1µs ±17% -78.66% (p=0.000 n=16+20)
name old alloc/op new alloc/op delta
TracingNoExporter-8 2.32kB ± 0% 0.40kB ± 0% -82.76% (p=0.000 n=20+20)
Tracing-8 6.32kB ± 0% 2.32kB ± 0% -63.30% (p=0.000 n=20+20)
name old allocs/op new allocs/op delta
TracingNoExporter-8 35.0 ± 0% 15.0 ± 0% -57.14% (p=0.000 n=20+20)
Tracing-8 215 ± 0% 35 ± 0% -83.72% (p=0.000 n=20+20)
Change-Id: I3cf25871fa49584819504b5c19aa580e5dd03395
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221740
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
These are just like the logging benchmarks but for tracing instead.
Also makes the log writer write out tracing events as well if it is
not in only errors mode
Change-Id: Ie00d7c80f7e2b9433787603261950f70ab1c1e9d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221739
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
This adds a type to events and makes the logging calls use it.
Change-Id: Iaa50fe2e332caae611b1e00424c878a3bc479feb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221741
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
The Tagger interface allowed for specifying a key in a tag list and having the
value be aquired from the context automatically. It was almost never used, and
the alternative (using the key to get the value) is not that much more long
winded, so it was not holding it's own weight from a complexity persective alone
but the performance cost of having to use a list of interface rather than a list
of tags was very large. See the benchstat improvements below for the difference
it makes to both speed and memory usage, especially in the no exporter case.
name old time/op new time/op delta
Baseline-8 341ns ± 2% 342ns ± 1% ~ (p=0.139 n=19+18)
LoggingNoExporter-8 2.46µs ± 5% 1.97µs ± 3% -19.88% (p=0.000 n=19+20)
Logging-8 13.3µs ± 2% 12.8µs ± 2% -3.42% (p=0.000 n=17+20)
LoggingStdlib-8 5.39µs ± 6% 5.34µs ± 3% ~ (p=0.692 n=20+19)
name old alloc/op new alloc/op delta
Baseline-8 80.0B ± 0% 80.0B ± 0% ~ (all equal)
LoggingNoExporter-8 728B ± 0% 440B ± 0% -39.56% (p=0.000 n=20+20)
Logging-8 2.75kB ± 0% 2.46kB ± 0% -10.53% (p=0.000 n=17+20)
LoggingStdlib-8 568B ± 0% 568B ± 0% ~ (all equal)
name old allocs/op new allocs/op delta
Baseline-8 5.00 ± 0% 5.00 ± 0% ~ (all equal)
LoggingNoExporter-8 32.0 ± 0% 23.0 ± 0% -28.12% (p=0.000 n=20+20)
Logging-8 88.0 ± 0% 79.0 ± 0% -10.23% (p=0.000 n=20+20)
LoggingStdlib-8 28.0 ± 0% 28.0 ± 0% ~ (all equal)
Change-Id: Ic203ad0c5de7451348976b999a0d038ac532dc39
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221737
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
We change the main exporter to be stored and fetched using atomics rather
than aquiring a mutex for a mild (but significant in the disabled case) speedup.
Also has the benefit of not holding a global lock over all telemetry operations.
benchstat of logging benchmatks before and after:
name old time/op new time/op delta
Baseline-8 329ns ± 2% 327ns ± 2% ~ (p=0.181 n=19+17)
LoggingNoExporter-8 3.08µs ± 3% 2.42µs ± 2% -21.42% (p=0.000 n=20+19)
Logging-8 13.7µs ± 2% 13.2µs ± 1% -3.49% (p=0.000 n=19+19)
LoggingStdlib-8 5.39µs ± 3% 5.41µs ± 2% ~ (p=0.177 n=19+20)
This is a replacement for https://go-review.googlesource.com/c/tools/+/212244
but built on the single exporter principle rather than the exporter list.
Change-Id: Icc99319c4357e0bcb63386c64372a733e8a76796
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221218
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
It is never invoked anyway, and it provices no useful benefit while complicating
the implementation, as it is the only non context aware method.
Change-Id: Id5a99439fedafdf4d71285e36103b4854cf3635a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/221540
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Instead we only have a single exporter, and it must delegate behaviour
to any other exporters it wants to include.
This removes a whole collection of suprises caused by init functions adding
new exporters to a list, as well as generally making things faster, at the small
expense of needing to implement a custom exporter if you want to combine the
features of a few other exporters.
This is essentially the opposite of https://go-review.googlesource.com/c/tools/+/212243
which will now be abandoned in favor of this approach.
Change-Id: Icacb4c1f0f40f99ddd1d82c73d4f25a3486e56ce
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220857
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Make all the benchmarks cleanly pass around the context to remove a non logging
difference.
Rename the non logging calls benchmark to Baseline
Change-Id: I24a33b0a817df403fb43c53b5f097bc1e9418af4
Reviewed-on: https://go-review.googlesource.com/c/tools/+/220520
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Several docstrings reference earlier names for the symbols they
document. This CL corrects those that I noticed while reading the lsp
code.
Change-Id: I1968459feff7011e070333c99eb149e72d3302de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214801
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
the current implementation likes to sort maps, so we make sure
tag lists are in sorted order already so that a stable encoder
produces the same result
Change-Id: Ia7ce05f35edb636817c354d9df02de753a48fe1d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/210216
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>