Skip to content

feat(otlp): experimental otlp support#2177

Merged
petethepig merged 8 commits intomainfrom
otlp
Nov 9, 2024
Merged

feat(otlp): experimental otlp support#2177
petethepig merged 8 commits intomainfrom
otlp

Conversation

@petethepig
Copy link
Copy Markdown
Collaborator

@petethepig petethepig commented Jul 27, 2023

@petethepig petethepig requested a review from a team as a code owner July 27, 2023 01:08
@petethepig petethepig marked this pull request as draft July 27, 2023 01:09
Comment thread pkg/api/api.go Outdated
{Desc: "Ring status", Path: "/distributor/ring"},
})

pprofileotlp.RegisterGRPCServer(a.server.GRPC, otlpHandler)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just so you know I don't think we expose GRPC endpoint anywhere in our infra nor in helm.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@cyriltovena yeah we might need a separate grpc server

Comment thread go.mod Outdated
go.opentelemetry.io/collector/pdata v1.0.0-rcv0012
)

replace go.opentelemetry.io/collector/pdata => ../opentelemetry-collector/pdata
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

to be clear, we won't have this dependency once this is ready to merge

Comment thread pkg/ingester/otlp/ingest_handler.go Outdated
// TODO(@petethepig): make it tenant-aware
ctx = tenant.InjectTenantID(ctx, tenant.DefaultTenantID)

h.log.Log("msg", "Export called")
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

we should remove this and any other logging messages like this

Comment thread pkg/validation/validate.go Outdated
return NewErrorf(MalformedProfile, "function id is 0")
}
}
// for _, location := range prof.Location {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I commented it out because something was breaking... that's not good, ideally we should figure out how to handle this properly

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm.. I uncommented it, but (as it is now) nothing fails 🤔

Comment thread pkg/ingester/otlp/ingest_handler.go Outdated
})
labelsDst = append(labelsDst, &typesv1.LabelPair{
Name: "service_name",
Value: "otlp_test_app4",
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@marcsanmi This and other labels is something we still need to figure out. There's multiple ways to add attributes in OTLP. Here's an example OTLP file encoded with YAML: https://gist.github.com/petethepig/0b5a0d71f8f5350d2082169690154f71

Look for attributes, attributetable and attributes.

Some labels are required in pyroscope. I would go with the defaults for __name__, service_name, __delta__ and pyroscope_spy listed here, except for service_name. it should be something else, maybe unknown?

Copy link
Copy Markdown
Contributor

@marcsanmi marcsanmi Nov 8, 2024

Choose a reason for hiding this comment

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

Done in bfa3f6c. I kept the defaults, but also added the capability to get service name from resource attributes, otherwise defaulting to unknown (even adding attributes processor is not supported in the collector profiles pipeline AFAIK)

Comment thread pkg/ingester/otlp/ingest_handler.go Outdated
func (h *ingestHandler) Export(ctx context.Context, er *pprofileotlp.ExportProfilesServiceRequest) (*pprofileotlp.ExportProfilesServiceResponse, error) {

// TODO(@petethepig): make it tenant-aware
ctx = tenant.InjectTenantID(ctx, tenant.DefaultTenantID)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should look into this and compare it to how it's done in other handlers too before merging

Comment thread pkg/ingester/otlp/ingest_handler.go Outdated
processedKeys := make(map[string]bool)

// Add resource attributes
labels = appendAttributesUnique(labels, rp.Resource.GetAttributes(), processedKeys)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right now we're adding all attributes as labels... do we want to set some limit?

Comment thread pkg/ingester/otlp/ingest_handler.go Outdated
_, ctx, err := user.ExtractFromGRPCRequest(ctx)
if err != nil {
level.Error(h.log).Log("msg", "failed to extract tenant ID from GRPC request", "err", err)
return &pprofileotlp.ExportProfilesServiceResponse{}, fmt.Errorf("failed to extract tenant ID from GRPC request: %w", err)
Copy link
Copy Markdown
Contributor

@marcsanmi marcsanmi Nov 8, 2024

Choose a reason for hiding this comment

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

Do we want to fail when we aren't able to extract tenant id? Or adding the default fallback?

@marcsanmi marcsanmi marked this pull request as ready for review November 8, 2024 17:34
@petethepig petethepig merged commit c2f396f into main Nov 9, 2024
@petethepig petethepig deleted the otlp branch November 9, 2024 00:03
@fandreuz
Copy link
Copy Markdown
Contributor

fandreuz commented May 22, 2025

Hi @petethepig, thanks for working on this feature. I'm using Pyroscope to prototype OTLP support in Async-Profiler. I noticed this went a bit out of sync with the OTLP Profile definition (open-telemetry/opentelemetry-proto#644, open-telemetry/opentelemetry-proto#650).

Do you plan to keep this closely in sync with the protocol? Would you be open to reviewing a PR?

@korniltsev
Copy link
Copy Markdown
Contributor

@fandreuz We will update the outdated otlp once we have some spare cycles. PR's are are very much welcome and appreciated, we'll be happy to review and mergge

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.

5 participants