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

[Draft, do not merge] Entities Prototype #5918

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

tigrannajaryan
Copy link
Member

Changes

  • Added entity refs to the Resource representation.
  • Made default Service detector produce a Resource with "service" entity type.
  • Modified stdout exporters to include entity information in the output.
  • Modified Resource.Merge() to use the new logic that takes the entities into account.
  • Added resource.NewWithEntities() to allow creating resources with entities.
  • Updated OTLP exporters to include entity info in the Resource.
  • Modified some existing resource some detectors to include entities (WithProcess, WithHostID) and added WithHostEntity to demonstrate how detectors work.

Results

Example output from dice example is below.

Note EntityRefs under the Resource.

{
        "Resource": {
                "Attributes": [
                        {
                                "Key": "host.id",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "4A135D30-F122-5869-9399-30339FDAE584"
                                }
                        },
                        {
                                "Key": "host.name",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "KYW9LWX6YV"
                                }
                        },
                        {
                                "Key": "process.command_args",
                                "Value": {
                                        "Type": "STRINGSLICE",
                                        "Value": [
                                                "/Users/tnajaryan/Library/Caches/JetBrains/GoLand2024.2/tmp/GoLand/___go_build_go_opentelemetry_io_otel_example_dice"
                                        ]
                                }
                        },
                        {
                                "Key": "process.executable.name",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "___go_build_go_opentelemetry_io_otel_example_dice"
                                }
                        },
                        {
                                "Key": "process.executable.path",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "/Users/tnajaryan/Library/Caches/JetBrains/GoLand2024.2/tmp/GoLand/___go_build_go_opentelemetry_io_otel_example_dice"
                                }
                        },
                        {
                                "Key": "process.owner",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "tnajaryan"
                                }
                        },
                        {
                                "Key": "process.pid",
                                "Value": {
                                        "Type": "INT64",
                                        "Value": 91752
                                }
                        },
                        {
                                "Key": "process.runtime.description",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "go version go1.23.2 darwin/arm64"
                                }
                        },
                        {
                                "Key": "process.runtime.name",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "go"
                                }
                        },
                        {
                                "Key": "process.runtime.version",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "go1.23.2"
                                }
                        },
                        {
                                "Key": "service.name",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "dice"
                                }
                        },
                        {
                                "Key": "service.version",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "0.1.0"
                                }
                        },
                        {
                                "Key": "telemetry.sdk.language",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "go"
                                }
                        },
                        {
                                "Key": "telemetry.sdk.name",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "opentelemetry"
                                }
                        },
                        {
                                "Key": "telemetry.sdk.version",
                                "Value": {
                                        "Type": "STRING",
                                        "Value": "1.23.0-rc.1"
                                }
                        }
                ],
                "SchemaURL": "https://opentelemetry.io/schemas/1.24.0",
                "EntityRefs": [
                        {
                                "Type": "service",
                                "Id": [
                                        "service.name",
                                        "service.version"
                                ],
                                "Attrs": null,
                                "SchemaURL": "https://opentelemetry.io/schemas/1.24.0"
                        },
                        {
                                "Type": "host",
                                "Id": [
                                        "host.id"
                                ],
                                "Attrs": [
                                        "host.name"
                                ],
                                "SchemaURL": "https://opentelemetry.io/schemas/1.24.0"
                        },
                        {
                                "Type": "process",
                                "Id": [
                                        "process.pid"
                                ],
                                "Attrs": [
                                        "process.runtime.description",
                                        "process.executable.name",
                                        "process.executable.path",
                                        "process.command_args",
                                        "process.owner",
                                        "process.runtime.name",
                                        "process.runtime.version"
                                ],
                                "SchemaURL": "https://opentelemetry.io/schemas/1.24.0"
                        }
                ]
        },
        "ScopeMetrics": []
}

@@ -31,8 +33,13 @@ import (
// (`*resource.Resource`). The `nil` value is equivalent to an empty
// Resource.
type Resource struct {
attrs attribute.Set
schemaURL string
attrs map[attribute.Key]attribute.Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type will need to remain comparable for backwards compatibility.

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 this pull request may close these issues.

2 participants