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

Consider using go module paths for scope name in demos #5412

Closed
dashpole opened this issue May 24, 2024 · 6 comments · Fixed by open-telemetry/opentelemetry.io#4831
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@dashpole
Copy link
Contributor

Problem Statement

I noticed the rolldice example has a single-word name for the meter and tracer:

const name = "rolldice"
var (
tracer = otel.Tracer(name)
meter = otel.Meter(name)
logger = otelslog.NewLogger(name)

I haven't checked other examples, but IMO we should consider doing this across all of them.

Proposed Solution

Since many users will use this as a starting point for their code, would it make more sense to use a "real" scope name? E.g. go.opentelemetry.io/otel/example/dice?

Alternatives

Keep simpler names for samples

@dashpole dashpole added the enhancement New feature or request label May 24, 2024
@dashpole
Copy link
Contributor Author

Also, should we document the convention that the go import path of the library producing the telemetry should be used as the scope name?

@MrAlias
Copy link
Contributor

MrAlias commented May 30, 2024

Also, should we document the convention that the go import path of the library producing the telemetry should be used as the scope name?

SGTM. Only question is where should we document this? Package docs?

@MrAlias
Copy link
Contributor

MrAlias commented May 30, 2024

To complete this, the docs site will need to be updated as well.

@MrAlias MrAlias added this to the v1.28.0 milestone May 30, 2024
@MrAlias MrAlias modified the milestones: v1.28.0, v1.29.0 Jul 2, 2024
@MrAlias MrAlias self-assigned this Jul 11, 2024
@MrAlias
Copy link
Contributor

MrAlias commented Jul 11, 2024

Also, should we document the convention that the go import path of the library producing the telemetry should be used as the scope name?

We already document this directly for the Meter and Tracer:

  • // The passed name needs to uniquely identify instrumentation code.
    // Therefore, it is recommended that name is the Go package name of the
    // library providing instrumentation (note: not the code being
    // instrumented). Instrumentation libraries can have multiple versions,
  • // A Meter should be scoped at most to a single package. The name needs to
    // be unique so it does not collide with other names used by
    // an application, nor other applications. To achieve this, the import path
    // of the instrumentation package is recommended to be used as name.

We should add this to the LoggerProvider:

// Logger returns a new [Logger] with the provided name and configuration.
//
// If name is empty, implementations need to provide a default name.
//
// Implementations of this method need to be safe for a user to call
// concurrently.
Logger(name string, options ...LoggerOption) Logger

@dashpole do you think this is adequate documentation?

@MrAlias
Copy link
Contributor

MrAlias commented Jul 11, 2024

We should add this to the LoggerProvider:

#5613

@dashpole
Copy link
Contributor Author

@dashpole do you think this is adequate documentation?

yes, thank you!

pellared added a commit that referenced this issue Jul 12, 2024
MrAlias added a commit that referenced this issue Jul 12, 2024
Part of #5412 

- Use the recommended package name for the instrumentation exemplified
in the repository.
- Use the recommended detection of a `TracerProvider` from passed
context.
@MrAlias MrAlias closed this as completed Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants