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

46 Commits

Author SHA1 Message Date
Tigran Najaryan
46d9687a35
Add Schema URL support to Resource (#1938)
This implements specification requirement:
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-creation

- Changes `resource.NewWithAttributes` to require a schema URL. The old function
  is still available as `resource.NewSchemaless`. This is a breaking change.
  We want to encourage using schema URL and make it a conscious choice to have a
  resource without schema.

- Merge schema URLs acccording to the spec in resource.Merge.

- Several builtin resource detectors now correctly populate the schema URL.

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2021-06-08 09:46:42 -07:00
Tigran Najaryan
bd935866f4
Add schema URL support to Tracer (#1889)
This adds support for schema URL to the Tracer according to the specification:
https://github.com/open-telemetry/opentelemetry-specification/pull/1666
(Link to replaced by the link to the spec after that PR is merged)

For the future: once the proto is updated we will need to populate the
schema_url field in the messages.
2021-05-27 15:22:38 -04:00
Aaron Clawson
c1f460e097
Update API configs. (#1921)
* Added Reason to Contributing and Updated TracerConfig

* PR comment fixup

* Changed how span Options work.

* Fix Markdown linting

* Added meter configs.

* Fixes from PR comments

* fix for missing instrument

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2021-05-27 07:53:56 -07:00
Robert Pająk
d23cc61b93
Refactor configs (#1882)
* trace: Refactor sampling config

* tracer: Refactor TracerProviderConfig

* Update the changelog

* Refactor sdk/metric/controller/basic config

* Refactor sdk/metric/processor/basic config

* Refactor sdk/resource config

* Refactor oteltest config

* Refactor exporters/otlp configs

* Refactor exporters/stdout config

* Refactor exporters/trace/jaeger configs

* Refactor exporters/trace/zipkin config

* Unexport stdout.NewConfig

* Refactor zipkin.go

* Refactor provider.go
2021-05-14 13:28:28 -07:00
Tyler Yahn
24a91628f1
Document the SSP is not for production use (#1844) 2021-04-27 09:23:09 -07:00
Dhruv Vora
0032bd6499
Fix default merging of resource attributes from environment variable (#1785)
* updated controller to merge default resource with environment resource

* updated TracerProvider to merge default resource with environment resource

* Added Changelog entry

* Added resource.Environment(), modified resource.Default() for environment vairable and WithResource() configuration for TracerProvider and Controller

* Update CHANGELOG.md

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

* Moved environment detector to defaultResource initialization, added test cases

* Changes to default resource initialization

* made changes to the test cases

* added merging of resource with environment resource

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
2021-04-21 14:53:12 -04:00
Tyler Yahn
2817c09174
Merge sdk/export/trace into sdk/trace (#1778)
* Merge sdk/export/trace into sdk/trace

* Update package move

* Add changes to changelog

* Add PR number to changelog
2021-04-07 08:03:43 -07:00
Injun Song
4beb70416e
sdk/trace: removing ApplyConfig and Config (#1693)
This patch removes `ApplyConfig` method and `Config` struct from
`go.opentelemetry.io/otel/sdk/trace` package.  To ensure valid config
for TracerProvider, it adds `ensureValidTracerProviderConfig` private
function.
Jaeger and Zipkin have been used the `Config` directly across package
boundaries. Since `Config` is removed, they can't use it. This change,
thus, replaces `WithSDK` with `WithSDKOptions`.

Resolves #1636, #1705.
2021-03-18 10:48:13 -07:00
Tyler Yahn
1d42be1601
Rename WithDefaultSampler TracerProvider option to WithSampler and update docs (#1702)
* Rename WithDefaultSampler TracerProvider option to WithSampler

The term "DefaultSampler" comes from early ideas of this project where
there would be overriding samplers lower in the trace SDK. This
overriding does not exist and if it is going to be introduced in the
future the sampler associated with the TracerProvider is already scoped
based on that association (no need to scope with a name). This renames
the TracerProvider option to not include this anachronism.

* Update PR number in CHANGELOG

* Propagate rename

* Update defaults documentation for TracerProvider

* Update sdk/trace/provider.go

Co-authored-by: Steven E. Harris <seh@panix.com>

* Update sdk/trace/provider.go

Co-authored-by: Steven E. Harris <seh@panix.com>
2021-03-18 09:34:47 -07:00
Injun Song
d75e268053
Avoid overriding configuration of tracer provider (#1633)
* sdk/trace: add missing options to tracer provider

This change adds `WithDefaultSampler` and `WithSpanLimits` to the tracer
provider and removed `WithConfig` from it.

Before this change, `WithConfig` is the only way to set sampler or
limits of a span. However, it is prone to misuse, since `WithConfig` can
override tracing configurations that are configured by `WithResource` or
`WithIDGenerator`.  Thus to fix this, it adds new functional options -
`WithDefaultSampler` and `WithSpanLimits` and removes `WithConfig`.

Resolves #1631.

* Update sdk/trace/provider.go

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

* Update sdk/trace/provider.go

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

* rebase and remove WithConfig

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2021-03-08 13:43:11 -08:00
Tyler Yahn
3dc91f2d76
Add ForceFlush method to TracerProvider (#1608)
* Add ForceFlush method to TracerProvider

The specification requires that a TracerProvider have a ForceFlush
method that can be set with a timeout, return any error to the caller,
and have all the registered span processors export their spans. This
updates the SpanProcessor.ForceFlush method to accept a context and
return an error and plumbs this method into a new ForceFlush method of
the SDK TracerProvider.

Additionally, this corrects the TracerProvider Shutdown method. This
method as well needs to return to the caller any failure it encounters
according to the specification. This returns an error if it cannot type
assert the spanProcessorStates or if shutting down a span processor
results in an error.

Resolves #1606

* Add changes to changelog

* Apply suggestions from code review

Co-authored-by: Steven E. Harris <seh@panix.com>

* Cancel export context when BSP stops

* Defer cancel call in BSP span processor funcs

Co-authored-by: Steven E. Harris <seh@panix.com>
2021-03-08 11:12:13 -08:00
Tyler Yahn
992837f195
Add TracerProvider tests to oteltest harness (#1607)
* Add TracerProvider tests to oteltest harness

* Update Tracer method docs

* Fix grammar
2021-03-03 12:09:58 -08:00
Tyler Yahn
841d2a5885
Rename local var new to not collide with builtin (#1610)
* Rename local var new to not collide with builtin

* Add missed var rename
2021-03-03 08:26:26 -08:00
Sam Xie
298c5a142f
Update span limits to conform with OpenTelemetry specification (#1535)
* Change the default span limit values to 128

* Rename and move MaxEventsPerSpan, MaxAttributesPerSpan, MaxLinksPerSpan into SpanLimits

* Add AttributePerEventCountLimit and AttributePerLinkCountLimit

* Update CHANGELOG

* Apply suggestions from code review

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

* Discard over limited attributes of links in `span.addLink`

* Change the type of droppedAttributeCount to int64

* Fix tests

* Fix label -> attribute package rename from merge

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2021-02-18 11:31:35 -08:00
ET
8fae0a644a
Create resource.Default() with required attributes/default values (#1507)
* Create resource.Default() with required attributes/default values

Add metric controller and tracer provider tests for resources

* Updated CHANGELOG

* PR comments

+ some small CHANGELOG PR addition, rewording
+ change default resource servicename to `unknown_service:go` (this
matches the Java codebase which uses `unknown_service:java`)
2021-02-15 12:28:37 -08:00
Krzesimir Nowak
af114baf6b
Call otel.Handle with non-nil errors (#1384)
* Call otel.Handle with non-nil errors

That's what normally happens in other call sites. Those two didn't
check it, but passed the "error" to Handle. The default, delegating
implementation of ErrorHandler was printing the error unconditionally,
which resulted in pointless lines like `2020/12/07 19:51:28 <nil>` in
demos, for example.

* Add tests

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-12-10 21:28:41 -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
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
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
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
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
Hui Kang
d75ccbb378
Add a Shutdown method to sdk TraceProvider (#1227)
* Add a Shutdown method to api TraceProvider

- sdktraceprovider shutdown span processors
- In examples, replace processosr shutdown with
  traceprovider's shutdown

Signed-off-by: Hui Kang <kangh@us.ibm.com>

* remove shutdown in the api provider interface

* Add context in parameter and return error

* handle error in shutdown

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-10-26 09:20:49 -07:00
Tyler Yahn
27c84d689d
Move trace api package into otel (#1229)
* Move trace API to otel

* Move tracetest to oteltest

* Update package documentation

* Remove old api/trace package

* Lint

* Add changes to CHANGELOG

* Add tests for rest of trace API

* Apply suggestions from code review

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

* Documentation fixes

Includes resolutions for review issues.

* Correct CHANGELOG post release

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
2020-10-08 19:58:56 -07:00
huikang
b97533a74b
Register/unregister in the fixed order (#1198)
- change the processors' map to array
- increase test coverage

Signed-off-by: Hui Kang <kangh@us.ibm.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2020-09-24 11:43:23 -07:00
Tyler Yahn
7d71867644
Rename *Provider names (#1190)
* Rename *Provider names

There is overlap in naming with MeterProviders and TracerProviders. This
is means the specification is not implemented and these types can not
exist in the same package (#1179). This makes each type and related
functions and types explicit.

* Add changes to CHANGELOG
2020-09-23 18:16:13 -04:00
Matej Gera
0041e2d26e
Rename ParentOrElse sampler to ParentBased and enhance it according to the spec (#1153)
* Rename ParentOrElse to ParentBased and enhance it according to the spec

- Renaming of type and sampler function
- Enhancing ParentBased with sampler options
- Set default samplers for each applicable parent-based case
- Adjust ShouldSample(...) func accordingly

* Adjust existing tests for ParentBased and add new ones

- add tests for ParentBased sampler options and description
- renaming in trace_test.go

* Update CHANGELOG.md

* PR feedback

- More clearer naming of structs; add comments where missing
- Adhere to the configuration style guide

* PR feedback - punctuation
2020-09-10 12:39:04 -07:00
JBD
9f4525847f
Convert XConfigure into constructors (#1155)
* Convert XConfigure into constructors

Previously, we discussed the possibility of converting
the config types into internal ones. But due to the
cyclic dependencies it introduces, we are only
converting XConfigure into constructors and document that
XConfig types are most likely are not going to be directly
used by developers.

In package documents, constructors will be nicely listed
under the config types and they won't be yet another
standalone symbol developers need to learn about.

Fixes #1130.

* Add the changes to the CHANGELOG
2020-09-10 15:15:17 -04:00
Tyler Yahn
422188a85f
Correct SDK trace Exporter interface (#1078)
* Update trace export interface

Move to conforming to the specification.

* Update documentation in export trace

* Update sdk trace provider to support new trace exporter

* Update SpanProcessors

Support the Provider changes and new trace exporter.

* Update the SDK to support the changes

* Update trace Provider to not return an error

* Update sdk with new Provider return

Also fix the testExporter ExportSpans method

* Update exporters with changes

* Update examples with changes

* Update Changelog

* Move error handling to end of shutdown

* Update exporter interface

Rename to SpanExporter to match specification. Add an error return value
to the Shutdown method based on feedback. Propagate these changes.

Remove the Stop method from the OTLP exporter to avoid confusion and
redundancy.

* Add test to check OTLP Shutdown honors context

* Add Jaeger exporter test for shutdown

* Fix race in Jaeger test

* Unify shutdown behavior and testing

* Update sdk/trace/simple_span_processor.go

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

Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
2020-09-09 10:19:03 -07:00
Tyler Yahn
0fec28040d
Update trace API TracerOption (#1109)
* Update Tracer configuration.

Conform to API option design outlined in #536.

Add tests to validate new TracerConfigure function

Drop the `instrumentation` prefix.

* Stick with instrumentationVersion for now

* Propagate changes

* Add changes to Changelog
2020-09-02 07:20:52 -07:00
Thomas Meire
e17e3caec8 Remove the orphaned RegisterSpanProcessor and UnregisterSpanProcessor #1077 2020-08-22 12:38:13 +02:00
MitchellDumovic
12992106de
Change default Sampler to ParentOrElse(AlwaysOn) (#989)
* Change default Sampler to ParentOrElse(AlwaysOn)

* add note to changelog
2020-07-29 19:10:12 -07:00
Tyler Yahn
a98bb979df
Update Tracer API with instrumentation version (#802)
* Update Tracer API with instrumentation version

Add option to the `Provider.Tracer` method to specify the
instrumentation version.

Update the global, noop, opentracing bridge, and default SDK
implementations.

This does not propagate the instrumentation library version to the
exported span. That is left for a follow-on PR.

* Revert trace_test.go

This is for the next PR.

* Update SDK to include version for default instrumentation

If the instrumentation library name is empty and the default
instrumentation is uses, include the SDK version.

* Update comments and documentation

* Remove default instrumentation version
2020-06-09 11:47:54 -07:00
Anthony J Mirabella
923a6c8afc Replace sdktrace.WithResourceAttributes() with WithResource() 2020-05-20 16:08:43 -04:00
Chen Yixiao
1301b6f3e4
Move core and key to kv package (#720)
* Move core to kv

* Move kv.Value to kv.value.Value

* Move key to kv
2020-05-13 16:06:03 -07:00
Joshua MacDonald
0bb12d9b1b
New api/label package, common label set impl (#651)
* New label set API

* Checkpoint

* Remove label.Labels interface

* Fix trace

* Remove label storage

* Restore metric_test.go

* Tidy tests

* More comments

* More comments

* Same changes as 654

* Checkpoint

* Fix batch labels

* Avoid Resource.Attributes() where possible

* Update comments and restore order in resource.go

* From feedback

* From feedback

* Move iterator_test & feedback

* Strenghten the label.Set test

* Feedback on typos

* Fix the set test per @krnowak

* Nit
2020-04-23 12:10:58 -07:00
Tyler Yahn
a485d0ec64
Update License header for all source files (#586)
* Update License header for all source files

- Add Apache 2.0 header to source files that did not have one.
- Update all existing headers dated to 2019 to be 2020
- Remove comma from License header to comply with the Apache 2.0
  guidelines.

* Update Copyright notice

Use the standard Copyright notices outlined by the
[CNCF](https://github.com/cncf/foundation/blob/master/copyright-notices.md#copyright-notices)
2020-03-23 22:41:10 -07:00
Rahul Patel
6ada85adba
add resource option to Provider. (#545)
- update otlp exporter to export resources.
2020-03-13 13:07:36 -07:00
Krzesimir Nowak
d9210f5676
Zipkin exporter (#495)
* Add zipkin exporter

The zipkin exporter implements the SpanBatcher interface. It follows
the current-at-the-time-of-writing document about conversion from
OpenTelemetry span data to Zipkin spans. Which means that endpoint
information is not yet filled.

* Fix typo in docs

* Add a zipkin example

This sends span information to a locally running zipkin collector.
Currently I have a problem getting the collector to show me the spans
after accepting them with HTTP 202. Not sure if this is because of
missing endpoint information.

* Make gitignore consistent

The fixed paths should be prefixed with a slash. The "relative" paths
mean that git will ignore all the files that end with the path.

* Add tests for zipkin exporter
2020-03-11 14:49:02 -07:00
Rahul Patel
161556aab8
Update provider to use AlwaysSampler instead of ProbabilitySampler (#506)
* update provider to use AlwaysSampler instead of ProbabilitySampler

* remove unused defaultSamplingProbability constant

* fix broken tests

* update failure message in test

* fix test description

Co-authored-by: Rahul Patel <rghetia@yahoo.com>
2020-03-05 13:29:51 -08:00
Jonas-Taha El Sesiy
1ab645fedb Consistently use pointer receivers for core.Number (#375)
Change all occurrences of value to pointer receivers
Add meta sys files to .gitignore
Code cleanup e.g.
- Don't capitalize error statements
- Fix ignored errors
- Fix ambiguous variable naming
- Remove unnecessary type casting
- Use named params

Fix #306
2019-12-09 13:03:11 -08:00
ferhat elmas
0f052af2f4 Rename GetTracer to Tracer (#347)
* Rename GetTracer to NewTracer

* Drop New prefix
2019-11-25 09:46:07 -08:00
Joshua MacDonald
68bd627ac2
Move export types into trace and metric-specific subdirs (#289) 2019-11-05 13:08:55 -08:00
Liz Fong-Jones
440b6653c9 remove rSSP and rBSP code, use NewProvider instead. (#271) 2019-11-01 16:35:18 -07:00
rghetia
15bfc5bb12
Namespace import path under "/otel" (#274)
Also fixes example module paths so that they use the vanity URL instead
of the github URL.

[Closes #184]
2019-11-01 11:40:29 -07:00
Edward Muller (SFDC)
f420f7409d sdk/trace: Test the Sampling Probability (#247)
* sdk/trace: Test the Sampling Probability

Closes #163

* Add tests for when the parent is sampled.
2019-10-29 16:53:50 -07:00
rghetia
b04db14146
WIP: Named tracer prototype (#227)
* named tracer prototype

* rename Manager to Provider.

* fix compile error after merge.

* rename Tracer method to GetTracer

* provider with options.

* update test.

* cleanup make circl-ci

* remove global config.

* some cleanup.

* use provider for bridge

* update propagation test.

* update examples and plugins.

* remove GlobalTracer methods.

* fix review comments.

* some more cleanup.

* remove unnecessary getTracer call in benchmark test.
2019-10-22 13:19:11 -07:00