1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-12 10:04:29 +02:00
Commit Graph

978 Commits

Author SHA1 Message Date
Joshua MacDonald
eb28005e2f
Metric Accumulator fix for SumObservers (#1381)
* Let SynchronizedMove(nil) reset and discard

* Add common test for SynchronizedMove(nil)

* End-to-end test for the Processor and SumObserver

* Implement SynchronizedMove(nil) six ways

* Lint

* Changelog

* Test no reset for wrong aggregator type; Fix four Aggregators

* Cleanup

* imports

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-12-10 18:13:08 -08:00
Anthony Mirabella
970755bd08
Enable support for externally-defined ID generators (#1363)
* Enable support for externally-defined ID generators

* Moved the SDK's `internal.IDGenerator` interface to the `sdk/trace`
package.
* Added `trace.WithIDGenerator()` `TracerProviderOption`.

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Update CHANGELOG.md with PR info

* Address PR feedback:

* Fix IDGenerator godoc comment
* rename type defaultIDGenerator to randomIDGenerator
* rename defIDGenerator() to defaultIDGenerator()

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>

* Rework trace.IDGenerator interface

* NewTraceID() -> NewIDs(ctx)
** Returns both TraceID and SpanID
* NewSpanID() -> NewSpanID(ctx, traceID)
** Returns only SpanID, has access to TraceID
* Both methods now receive a context, from which they may extract
information
* startSpanInternal() updated to receive a context to pass to the ID
generator

* Drop outdated comment from docblock

Co-authored-by: Krzesimir Nowak <qdlacz@gmail.com>

Co-authored-by: Krzesimir Nowak <qdlacz@gmail.com>
2020-12-09 20:30:32 -05:00
Krzesimir Nowak
0021ab0a3a
Rework proto generation (#1371)
* Rework proto generation

The changes here are:

- Fix the default goal (using "default" target is not doing it).

- Bail out with a useful message if proto submodule is not checked
  out.

- Replace the use of docker image with downloading the protoc binary
  and building the gogofast plugin ourselves. This gives us a greater
  control over the invocation of protoc.

- Use rsync to copy the generated code, instead of pax. Pax did not
  work for me (it was complaining about the unknown -0 flag).

The control over the protoc invocation will be useful later, when we
will want to generate a code with data structures in one place and the
collector code elsewhere. The collector code may or may not depend on
gRPC, but data structures have no need for it. This split will happen
when we move the gRPC code out of the OTLP exporter module into a
submodule.

Getting rid of docker has the upside that the generated files do not
belong to root, so there is no hassle of changing the ownership of the
files, and it is not requires to use sudo for the `clean` target. And
not using docker is faster.

The downside of this work is that it depends on more tools: rsync,
unzip and wget. I can only hope that macOS users have those tools too,
and that those tools are invoked the same.

* Update protogen workflow
2020-12-07 09:36:06 -08:00
José Carlos Chávez
787e3f457a
chore(zipkin-exporter): relay on the status code for the request but still read the response body. (#1328)
* chore(zipkin-exporter): relay on the status code for the request but still read the response body.

* fix(zipkin-exporter): fix tests.

* chore(zipkin-exporter): adds changelog.

* chore: 202 -> http.StatusAccepted

Co-authored-by: Chris Bandy <bandy.chris@gmail.com>

* chore: 202 -> http.StatusAccepted

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>

Co-authored-by: Chris Bandy <bandy.chris@gmail.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-12-03 09:51:09 -08:00
Krzesimir Nowak
66db2d845b
Build examples last (#1370)
Examples are "leaf" packages, that pull some other packages. So build
the other packages first to get and fix all the errors there, before
building the examples.
2020-12-01 08:02:36 -08:00
dependabot[bot]
958041ddf6
Bump github.com/golangci/golangci-lint in /internal/tools (#1375)
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.32.2 to 1.33.0.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/golangci/golangci-lint/compare/v1.32.2...v1.33.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-30 10:38:52 -08:00
dependabot[bot]
e1ff2d15cf
Bump github.com/google/go-cmp from 0.5.3 to 0.5.4 (#1374)
* Bump github.com/google/go-cmp from 0.5.3 to 0.5.4

Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.3 to 0.5.4.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.3...v0.5.4)

Signed-off-by: dependabot[bot] <support@github.com>

* Auto-fix go.sum changes in dependent modules

* Auto-fix go.sum changes in dependent modules

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-30 10:31:41 -08:00
luckyxiaoqiang
5d0372dd2e
Fix typo in comment (#1377) 2020-11-30 08:54:38 -08:00
Guangwen Feng
55ff27787d
Fix golint issue caused by typo (#1372)
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
2020-11-27 09:44:12 -08:00
Krzesimir Nowak
5a728db2e9
Another batch of cleanups in otlp exporter (#1357)
* Move connection logic into grpcConnection object

If we will need to maintain more than one connection in future, this
splitting off will come in handy.

Co-authored-by: Stefan Prisca <stefan.prisca@gmail.com>

* Make another channel a signal channel

There is another channel that serves as a one-time signal, where
channel's data type does not matter.

* Reorder and document connection members

This is to make clear that the lock is guarding only the connection
since it can be changed by multiple goroutines, and other members are
either atomic or read-only.

* Move stop signal into connection

The stop channel was rather useless on the exporter side - the primary
reason for existence of this channel is to stop a background
reconnecting goroutine. Since the goroutine lives entirely within
grpcConnection object, move the stop channel here. Also expose a
function to unify the stop channel with the context cancellation, so
exporter can use it without knowing anything about stop channels.

Also make export functions a bit more consistent.

* Do not run reconnection routine when being stopped too

It's possible that both disconnected channel and stop channel will be
triggered around the same time, so the goroutine is as likely to start
reconnecting as to return from the goroutine. Make sure we return if
the stop channel is closed.

* Nil clients on connection error

Set clients to nil on connection error, so we don't try to send the
data over a bad connection, but return a "no client" error
immediately.

* Do not call new connection handler within critical section

It's rather risky to call a callback coming from outside within a
critical section. Move it out.

* Add context parameter to connection routines

Connecting to the collector may also take its time, so it can be
useful in some cases to pass a context with a deadline. Currently we
just pass a background context, so this commit does not really change
any behavior. The follow-up commits will make a use of it, though.

* Add context parameter to NewExporter and Start

It makes it possible to limit the time spent on connecting to the
collector.

* Stop connecting on shutdown

Dialling to grpc service ignored the closing of the stop channel, but
this can be easily changed.

* Close connection after background is shut down

That way we can make sure that there won't be a window between closing
a connection and waiting for the background goroutine to return, where
the new connection could be established.

* Remove unnecessary nil check

This member is never nil, unless the Exporter is created like
&Exporter{}, which is not a thing we support anyway.

* Update changelog

Co-authored-by: Stefan Prisca <stefan.prisca@gmail.com>
2020-11-24 11:50:05 -08:00
Krzesimir Nowak
e0819780f9
Move opencensus example to the example directory (#1359)
And update .gitignore, so the built binary does not show up in git
status.
2020-11-20 13:34:40 -08:00
Tyler Yahn
575df22b79
Release v0.14.0 (#1355)
* Prepare for releasing v0.14.0

* Update changelog
2020-11-20 08:36:54 -08:00
David Ashpole
34aa6816c1
revert part of #1334. Move binary propagation to contrib (#1353)
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
2020-11-19 18:09:39 -08:00
Krzesimir Nowak
6eb68013b5
Some cleanups in otlp exporter (#1350)
* Drop WorkerCount option

This is not a good option - the user isn't likely to know how many
worker goroutines is optimal. This should be something that an
exporter should figure out itself. The second problem with the option
is that it is specific to the metric transformation from SDK export
format into protobuf. When the exporter starts supporting other
protocols (HTTP/JSON for example), this option may be of no use. So
the option should rather belong to the protocol, not to the
exporter. Currently both mean the same, but later they will be
separated, and this option breaks the separation.

* Make stop channel a typical signalling channel

Signalling channels are idiomatically defined as chan struct{}, so
let's make it so, to avoid confusion about the meaning of the bool
type.

* Close a race when grpc connection is closed multiple times

If several goroutines call Shutdown at the same time, then the
following scenario is possible:

goroutine A locks a mutex, reads a started member, unlocks the mutex
and gets preempted

goroutine B locks a mutex, reads a started member, unlocks the mutex
and gets preempted

goroutine A does not return early in the "if !started" conditional and
continues to close the connection and execute the rest of the function
(where it finally sets the started member to false), gets preempted

goroutine B also does not return early, because it got a copy of
started before goroutine A set it to false, so it tries to close the
connection again.

* Update changelog
2020-11-19 21:03:25 -05:00
Tyler Yahn
5b5b4ab1ea
Update OTLP to v0.6.0 (#1354)
* Update opentelemetry-proto submodule to v0.6.0

* Update generated code

* Update the OTLP exporter with new proto

* Update CHANGELOG
2020-11-19 20:57:17 -05:00
David Ashpole
4619c068e2
Add opencensus bridge example and readme (#1348)
* add opencensus bridge example

* Apply suggestions from code review

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-19 12:41:09 -08:00
Daniil Rutskiy
2c2f9852fe
Add missing tests for attributesMap (#1337)
* Rename sdk/trace/attributesMap.go -> sdk/trace/attributesmap.go

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Add missing tests for attributesMap

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Add missing license header

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Delete underscores in test names

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Tests clean up

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>
2020-11-18 19:15:26 -05:00
Hanshuo Tan
fd3c82bec5
support exact kind in OTLP metrics exporter (#1309)
* support exact kind in OTLP metrics exporter

* add change log

* rename function

* inline start time and end time variables

* fix test

* add test for exact int data points

* add test for exact float data points

* use newly introduced number package for numbers according to upstream change

* fix package ref
2020-11-18 14:35:37 -05:00
Chris Bandy
c857a3da18
Pass options to configured TracerProvider (#1329)
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-17 10:02:21 -08:00
Krzesimir Nowak
7022c12bfc
Update the package docs for the new API layout (#1346) 2020-11-17 10:30:22 -05:00
David Ashpole
bbc9465ddb
Add opencensus binary propagation to bridge (#1334)
* add opencensus binary propagation bridge

* Update bridge/opencensus/binary/binary.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update bridge/opencensus/doc.go

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* address comments

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-16 10:35:25 -08:00
Sean Schade
73a05393a0
chore(semconv): Add PR number to changelog (#1323)
feat(semconv): Add DeploymentEnvironmentKey to semconv package
2020-11-16 10:29:28 -08:00
Justin Foote
3207770f88
Set telemetry.sdk.name resource attribute to "opentelemetry" (#1332)
* Set telemetry.sdk.name resource attribute to "opentelemetry"

* Update config_test.go to correct `telemetry.sdk.name`

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-16 10:00:59 -08:00
Ross Light
380d9455fd
s/HTTPUrlKey/HTTPURLKey/ in semconv (#1338)
* s/HTTPUrlKey/HTTPURLKey/ in semconv

* Fix build

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-16 09:55:25 -08:00
Krzesimir Nowak
3d6e8b5078
Move Version function and code from global to toplevel (#1330)
* Move global code to toplevel package

* Move version function to toplevel package

* Update changelog

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-16 09:30:54 -08:00
dependabot[bot]
20c78fed0a
Bump github.com/google/go-cmp from 0.5.2 to 0.5.3 (#1339)
* Bump github.com/google/go-cmp from 0.5.2 to 0.5.3

Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.2 to 0.5.3.
- [Release notes](https://github.com/google/go-cmp/releases)
- [Commits](https://github.com/google/go-cmp/compare/v0.5.2...v0.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

* Auto-fix go.sum changes in dependent modules

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-16 09:11:53 -08:00
Johannes Liebermann
070b657c21
Add parent context to SpanProcessor.OnStart (#1333)
* Add parent context to SpanProcessor.OnStart

The spec requires doing so. Right now SpanProcessor implementations
aren't doing anything with this argument.

* Update changelog

* Fix typo in test name
2020-11-16 11:45:49 -05:00
Krzesimir Nowak
63a11144cf
Move baggage and propagation to separate packages (#1325)
* Move propagation code to propagation package

* Move baggage code to baggage package

* Update changelog

* Make docs of baggage.Set more clear

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-13 07:34:24 -08:00
David Ashpole
f6df5df938
add opencensus tracing bridge (#1305) 2020-11-12 10:51:52 -08:00
Andrew Hsu
27aa1f6011
update go documentation badge image (#1322)
Signed-off-by: Andrew Hsu <xuzuan@gmail.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-12 07:33:04 -08:00
Krzesimir Nowak
75d4911c95
Move metric code to a separate package (#1321)
* Move metrics code to metric package

* Update changelog
2020-11-12 07:28:32 -08:00
Krzesimir Nowak
386331a472
Prepare to move metrics code to separate subpackage (#1316)
* Move registry package under metric

* Move Number type to the metric/number subpackage

This also renames NumberKind type to Kind.

* Update changelog

* Drop outdated comment
2020-11-11 07:24:12 -08:00
Joshua MacDonald
f9984f2d4e
Support configurable AggregationTemporality in exporters; add OTLP missing sum point temporality/monotonic fields (#1296)
* Restructure ExportKindSelector helpers; eliminate PassThroughExportKind; add StatelessExportKindSelector()

* WithExportKindSelector(); Additional testing

* Changelog update

* Test the new selectors

* From review feedback

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-10 07:44:42 -08:00
alrex
3a06b393b9
Update span collection limits to 1000 (#1318)
* set collection limit to 1000

* update changelog

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-10 07:40:01 -08:00
Tawhid Hannan
b7508da6fa
Export non monotonic counters as gauge values from the prometheus exporter (#1269)
* Export non monotonic counters as gauge values from the prometheus exporter

* Add a test to ensure the pre-existing LastValue pathway on the collector exports the last value

* Add a TODO around refactoring the prometheus test to verify metadata as well

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-09 13:52:05 -08:00
Tyler Yahn
757030dc78
Update Span End method documentation (#1310)
* Update Span End method documentation

Updates to the Span after End is called result it potentially
inconsistent views of the Span between the code defining it and the
ultimate receiver of the Span data. This corrects the documented
language of the API to prevent this from happening.

* Add changes to changelog
2020-11-09 10:57:34 -08:00
Tyler Yahn
a354c026b6
Clean up SDK span field docs (#1312)
Remove cruft about spanStore.

Update documentation about how span.mu is used (related to #1311).

Reformat to conform with idiomatic field documentation.
2020-11-09 10:40:02 -08:00
dependabot[bot]
1041adaf58
Bump github.com/golangci/golangci-lint in /internal/tools (#1315)
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.32.1 to 1.32.2.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/golangci/golangci-lint/compare/v1.32.1...v1.32.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-09 10:21:12 -08:00
Krzesimir Nowak
3268501910
Move tracing code to trace package (#1307)
* Move tracing code to trace package

* Update changelog
2020-11-06 17:13:31 -05:00
Matej Gera
9ac3a08eef
Remove MockSpan and MockTracer (#1306)
* Remove MockSpan and MockTracer

* Update CHANGELOG

Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2020-11-05 08:13:19 -08:00
Krzesimir Nowak
c9ae670c8a
Fix zipkin example module name (#1308)
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-05 07:55:25 -08:00
José Carlos Chávez
e22a48de5a
chore: adds vanity import for files that don't have it. (#1297) 2020-11-04 09:10:58 -08:00
Daniil Rutskiy
911d7be43d
Check marshalled value instead of iface (#1299)
* Check marshalled value

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Move change to Fixed section

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-11-02 08:27:41 -08:00
dependabot[bot]
238d2c015c
Bump github.com/golangci/golangci-lint in /internal/tools (#1301)
Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.32.0 to 1.32.1.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/golangci/golangci-lint/compare/v1.32.0...v1.32.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-01 08:52:11 -08:00
Joshua MacDonald
187adeb251
Change resource.New() to use functional options; add builtin attributes for (host.*, telemetry.sdk.*) (#1235)
* Add a resource.Configure() with functional options

* Add a changelog

* Add tests for builtin resources

* Rename to WithoutBuiltin

* Add new test; restore environment after tests

* Apply feedback

* Apply suggestions from code review

❤️

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Comment edits

* Rename New, former method NewFromAttributes

* NewFromAttributes->NewWithAttributes

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-10-31 11:16:55 -07:00
Tyler Yahn
034195692a
Update README and documentation to better communicate pre-GA state (#1281)
* Update README

Move project status to top of project documentation and add explicit
warnings that this project may introduce breaking changes.

* Add disclaimer to public packages docs

* Use explicit warning in README
2020-10-29 09:23:13 -07:00
Jaana Dogan
23e32b19ec
Minor readability fixes to the Jeager example (#1282)
Consistency with deferring span.End, variable names.

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-10-28 08:08:13 -07:00
Daniil Rutskiy
d98ad1042c
Fix Code.UnmarshalJSON to work with valid json only (#1276)
* Remove quotes from UnmarshalJSON

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Update CHANGELOG.md

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Fix issue number in CHANGELOG.md

* Fix 'Code.UnmarshalJSON' to work with valid json only

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Extend test data for TestCodeUnmarshalJSONErrorInvalidData

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>

* Delete useless cond, extend test data

Signed-off-by: Daniil Rutskiy <dstdfx@gmail.com>
2020-10-27 15:30:49 -07:00
Ilya Kaznacheev
a6b31e0da1
Update SpanProcessor Shutdown with context and error (#1264)
* 1232: update SpanProcessor Shutdown with context and error

* 1232: add changelog info

* 1232: fix CI error, rm commented code

* 1232: fix CI unhandled error

* 1232: Done commit properly

* Add shutdown error handling

* Merge branch 'master' into update-span-processor

* Revert now unneeded context declaration move

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2020-10-26 19:06:55 -07:00
Bryan Boreham
412ee70ad2
Fix typo in example (#1278) 2020-10-26 12:23:40 -07:00