Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add tags to spans #312

Closed
genebean opened this issue Aug 7, 2020 · 3 comments · Fixed by #348
Closed

Unable to add tags to spans #312

genebean opened this issue Aug 7, 2020 · 3 comments · Fixed by #348

Comments

@genebean
Copy link
Contributor

genebean commented Aug 7, 2020

As best as I can tell from reading through things, there doesn't seem to be a way for me to add tags yet. My specific use case here is adding tags to an app instrumented via the opentelemetry-ruby/instrumentation/sinatra/.

@genebean genebean changed the title Unabel to add tags to spans Unable to add tags to spans Aug 7, 2020
@mwear
Copy link
Member

mwear commented Aug 10, 2020

👋 @genebean. In OpenTelemetry tags are referred to as attributes. There is a Span#add_attribute method for adding them. If you are trying to get at a Span that has been created by auto-instrumentation, it might be available by calling Tracer#current_span, although that will depend on what other work is being traced at the time.

Let us know if you still have questions.

@genebean
Copy link
Contributor Author

When configuring ddtrace I can do this:

Datadog.configure do |c|
  c.tracer tags: {
    'service_name' => 'my-application-name',
    'service.version' => version,
  }
end

This gem currently limits me to doing this:

OpenTelemetry::SDK.configure do |c|
  c.add_span_processor(
    OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
      OpenTelemetry::Exporters::Jaeger::Exporter.new(
        service_name: 'my-application-name', host: jaeger_host, port: 6831
      )
    )
  )
end

The key difference here is that the only tag / attribute I can set at startup is service_name where as with ddtrace I can set any number of arbitrary tags. The specific issue this is causing for me is that I cannot add service.version from within the application.

@fbogsany
Copy link
Contributor

The correct place to do this is with a Resource, like:

OpenTelemetry::SDK.configure do |c|
  c.resource = OpenTelemetry::SDK::Resources::Resource.create({
    'service_name' => 'my-application-name',
    'service.version' => version,
  })
end

Unfortunately, we haven't yet implemented the mapping from OTel's Resource to Jaeger's Process yet:

def encoded_process
@encoded_process ||= begin
tags = [] # TODO: figure this out.
# tags = OpenTelemetry.tracer.resource.label_enumerator.map do |key, value|
# Thrift::Tag.new('key' => key, 'vType' => Thrift::TagType::STRING, 'vStr' => value)
# end
Thrift::Process.new('serviceName' => @service_name, 'tags' => tags)
end
end

#314 discusses how we might do this. We don't have consensus yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants