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

V2 profiling #541

Merged
merged 14 commits into from
Nov 19, 2024
Prev Previous commit
Next Next commit
Run hatch run fmt
  • Loading branch information
pmcollins committed Nov 15, 2024
commit 75a80058e4de57e51550e11ef9466f5d3d501cfe
2 changes: 1 addition & 1 deletion src/splunk_otel/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from opentelemetry.sdk._configuration import _initialize_components, _OTelSDKConfigurator
from opentelemetry.sdk._configuration import _OTelSDKConfigurator

from splunk_otel.env import Env
from splunk_otel.profile import start_profiling
Expand Down
10 changes: 8 additions & 2 deletions src/splunk_otel/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
from opentelemetry.sdk.environment_variables import OTEL_EXPORTER_OTLP_HEADERS

from splunk_otel.env import (DEFAULTS, Env, OTEL_METRICS_ENABLED, SPLUNK_ACCESS_TOKEN,
SPLUNK_TRACE_RESPONSE_HEADER_ENABLED, X_SF_TOKEN)
from splunk_otel.env import (
DEFAULTS,
OTEL_METRICS_ENABLED,
SPLUNK_ACCESS_TOKEN,
SPLUNK_TRACE_RESPONSE_HEADER_ENABLED,
X_SF_TOKEN,
Env,
)
from splunk_otel.propagator import ServerTimingResponsePropagator


Expand Down
3 changes: 2 additions & 1 deletion src/splunk_otel/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

import opentelemetry.context
import wrapt
from opentelemetry._logs import get_logger, Logger, set_logger_provider, SeverityNumber
from opentelemetry._logs import Logger, SeverityNumber, get_logger, set_logger_provider
from opentelemetry.context import Context
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter
from opentelemetry.sdk._logs import LoggerProvider, LogRecord
from opentelemetry.sdk._logs._internal.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import Resource
from opentelemetry.trace import TraceFlags
from opentelemetry.trace.propagation import _SPAN_KEY

from splunk_otel import profile_pb2

_profiling_timer = None
Expand Down
1 change: 0 additions & 1 deletion src/splunk_otel/profile_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/ott_profile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from oteltest import Telemetry
from oteltest.telemetry import num_logs

from ott_lib import project_path, trace_loop

if __name__ == "__main__":
Expand Down
8 changes: 3 additions & 5 deletions tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from google.protobuf.json_format import MessageToDict
from opentelemetry._logs import Logger
from opentelemetry.sdk.resources import Resource

from splunk_otel import profile_pb2
from splunk_otel.profile import pb_profile_from_str, pb_profile_to_str, ProfilingScraper, \
stacktraces_to_cpu_profile
from splunk_otel.profile import ProfilingScraper, pb_profile_from_str, pb_profile_to_str, stacktraces_to_cpu_profile


@pytest.fixture
Expand All @@ -34,7 +32,7 @@ def pb_profile_fixture():

def load_json(fname):
parent_dir = dirname(abspath(__file__))
with open(f"{parent_dir}/fixtures/{fname}", "r") as f:
with open(f"{parent_dir}/fixtures/{fname}") as f:
return json.load(f)


Expand Down Expand Up @@ -85,7 +83,7 @@ def do_work(time_ms):
total = 0.0
while now < target:
value = random.random()
for _ in range(0, 10000):
for _ in range(10000):
value = value + random.random()

total = total + value
Expand Down