Skip to content

Commit

Permalink
fix: pprof ParseToPprof (grafana#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
korniltsev authored Sep 8, 2023
1 parent fc49aaa commit 5f8be6f
Show file tree
Hide file tree
Showing 49 changed files with 465 additions and 10,376 deletions.
2 changes: 1 addition & 1 deletion examples/python/simple/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9
FROM python:3.11

WORKDIR /usr/src/app

Expand Down
13 changes: 10 additions & 3 deletions examples/python/simple/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/usr/bin/env python3

import logging
import os

import pyroscope

l = logging.getLogger()
l.setLevel(logging.DEBUG)

addr = os.getenv("PYROSCOPE_SERVER_ADDRESS") or "http://pyroscope:4040"
print(addr)

pyroscope.configure(
application_name = "simple.python.app",
server_address = "http://pyroscope:4040",
application_name = "simple.python.app",
server_address = addr,
enable_logging = True,
)

def work(n):
Expand Down
2 changes: 1 addition & 1 deletion examples/python/simple/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pyroscope-io==0.7.1
pyroscope-io==0.8.5
4 changes: 2 additions & 2 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,15 @@ func (d *Distributor) PushParsed(ctx context.Context, req *distributormodel.Push
}
}

haveRawPprof := req.RawProfileType == ""
haveRawPprof := req.RawProfileType == distributormodel.RawProfileTypePPROF
d.bytesReceivedTotalStats.Inc(int64(req.RawProfileSize))
d.bytesReceivedStats.Record(float64(req.RawProfileSize))
if !haveRawPprof {
// if a single profile contains multiple profile types/names (e.g. jfr) then there is no such thing as
// compressed size per profile type as all profile types are compressed once together. So we can not count
// compressed bytes per profile type. Instead we count compressed bytes per profile.
profName := req.RawProfileType // use "jfr" as profile name
d.metrics.receivedCompressedBytes.WithLabelValues(profName, tenantID).Observe(float64(req.RawProfileSize))
d.metrics.receivedCompressedBytes.WithLabelValues(string(profName), tenantID).Observe(float64(req.RawProfileSize))
}

for _, series := range req.Series {
Expand Down
7 changes: 6 additions & 1 deletion pkg/distributor/model/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import (
"github.com/grafana/pyroscope/pkg/pprof"
)

type RawProfileType string

const RawProfileTypePPROF = RawProfileType("pprof")
const RawProfileTypeJFR = RawProfileType("jfr")

type PushRequest struct {
RawProfileSize int
RawProfileType string // should be set if not pprof, eg jfr
RawProfileType RawProfileType

Series []*ProfileSeries
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/ingester/pyroscope/ingest_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ func (h ingestHandler) ingestInputFromRequest(r *http.Request) (*ingestion.Inges
input.Profile = &pprof.RawProfile{
FormDataContentType: contentType,
RawData: b,
StreamingParser: true,
PoolStreamingParser: true,
}
}

Expand Down
Loading

0 comments on commit 5f8be6f

Please sign in to comment.