Skip to content

Commit

Permalink
TEST: add some random logging
Browse files Browse the repository at this point in the history
Summary:
Testing OTEL in PyTorch to see what automation workflows break.
This change won't be commited into the main branch.

ghstack-source-id: 099915604e42c865b6de349fd66c99dc81885c3d
Pull Request resolved: #125176
  • Loading branch information
c-p-i-o committed Apr 30, 2024
1 parent f7f018a commit 56e1c4f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,7 @@ cc_library(
":torch",
":shm",
"@pybind11",
"@io_opentelemetry_cpp//api",
],
)

Expand Down
10 changes: 9 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,20 @@ http_archive(
)

http_archive(
name = "com_github_opentelemetry-cpp",
name = "io_opentelemetry_cpp",
sha256 = "c7e7801c9f6228751cdb9dd4724d0f04777ed53f524c8828e73bf4c9f894e0bd",
strip_prefix = "opentelemetry-cpp-1.14.2",
urls = [
"https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.14.2.tar.gz",
],
)

new_local_repository(
name = "opentelemetry-api",
build_file = "//third_party:opentelemetry-cpp.BUILD",
path = "third_party/opentelemetry-cpp",
)

new_local_repository(
name = "gloo",
build_file = "//third_party:gloo.BUILD",
Expand Down
14 changes: 14 additions & 0 deletions torch/csrc/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <c10/core/CPUAllocator.h>
#include <torch/csrc/THP.h>
#include <torch/csrc/serialization.h>
#include <opentelemetry/common/timestamp.h>
#include <opentelemetry/trace/tracer.h>
#include <opentelemetry/metrics/noop.h>

using opentelemetry::common::SystemTimestamp;

template <class io>
Py_ssize_t doPartialRead(io fildes, void* buf, size_t nbytes);
Expand All @@ -27,6 +32,15 @@ static Py_ssize_t doPartialPythonWrite(

template <>
Py_ssize_t doPartialRead<int>(int fildes, void* buf, size_t nbytes) {
opentelemetry::trace::StartSpanOptions start;
start.start_system_time = SystemTimestamp(std::chrono::nanoseconds(300));
std::shared_ptr<opentelemetry::metrics::Counter<uint64_t>> counter{
new opentelemetry::metrics::NoopCounter<uint64_t>("testi2", "none", "unitless")};

std::map<std::string, std::string> labels = {{"k1", "v1"}};
counter->Add(10, labels);
counter->Add(10, labels, opentelemetry::context::Context{});
counter->Add(2);
return read(fildes, buf, nbytes);
}

Expand Down

0 comments on commit 56e1c4f

Please sign in to comment.