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

feat(otlp): experimental otlp support #2177

Merged
merged 8 commits into from
Nov 9, 2024
Merged

feat(otlp): experimental otlp support #2177

merged 8 commits into from
Nov 9, 2024

Conversation

petethepig
Copy link
Member

@petethepig petethepig commented Jul 27, 2023

pkg/api/api.go Outdated
a.RegisterRoute("/ingest", pyroscopeHandler, true, true, "POST")
a.RegisterRoute("/pyroscope/ingest", pyroscopeHandler, true, true, "POST")
pushv1connect.RegisterPusherServiceHandler(a.server.HTTP, d, a.grpcAuthMiddleware)
a.RegisterRoute("/distributor/ring", d, false, true, "GET", "POST")
a.indexPage.AddLinks(defaultWeight, "Distributor", []IndexPageLink{
{Desc: "Ring status", Path: "/distributor/ring"},
})

pprofileotlp.RegisterGRPCServer(a.server.GRPC, otlpHandler)
Copy link
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
Member 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

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

replace go.opentelemetry.io/collector/pdata => ../opentelemetry-collector/pdata
Copy link
Member 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

// TODO(@petethepig): make it tenant-aware
ctx = tenant.InjectTenantID(ctx, tenant.DefaultTenantID)

h.log.Log("msg", "Export called")
Copy link
Member 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

return NewErrorf(MalformedProfile, "function id is 0")
}
}
// for _, location := range prof.Location {
Copy link
Member 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
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 🤔

})
labelsDst = append(labelsDst, &typesv1.LabelPair{
Name: "service_name",
Value: "otlp_test_app4",
Copy link
Member 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
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)

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
Member 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

pkg/ingester/otlp/ingest_handler.go Outdated Show resolved Hide resolved
processedKeys := make(map[string]bool)

// Add resource attributes
labels = appendAttributesUnique(labels, rp.Resource.GetAttributes(), processedKeys)
Copy link
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?

_, 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
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?

@petethepig petethepig merged commit c2f396f into main Nov 9, 2024
18 checks passed
@petethepig petethepig deleted the otlp branch November 9, 2024 00:03
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.

3 participants