You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by GitBox <gi...@apache.org> on 2022/01/06 20:41:10 UTC

[GitHub] [trafficserver] sudheerv commented on a change in pull request #8495: Add support for OpenTracing

sudheerv commented on a change in pull request #8495:
URL: https://github.com/apache/trafficserver/pull/8495#discussion_r779851680



##########
File path: include/tscore/Tracing.h
##########
@@ -0,0 +1,119 @@
+/** @file
+
+  ATS Tracing API
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#pragma once
+
+#include <atomic>
+#include <memory>
+#include <string_view>
+#include "tscore/ink_assert.h"
+#include "tscore/ink_config.h"
+
+#if TS_USE_OPENTRACING
+#include "tscore/Tracing_opentracing.h"
+#else
+using TRACER = int;
+inline void
+tracing_tag(TRACER &out, std::string_view name, std::string_view value)
+{
+  ink_assert(!"No tracing library is available");
+}
+
+inline void
+tracing_tag(TRACER &out, std::string_view name, int value)
+{
+  ink_assert(!"No tracing library is available");
+}
+
+inline void
+tracing_log(TRACER &out, std::string_view category, std::string_view tag)
+{
+  ink_assert(!"No tracing library is available");
+}
+
+inline void
+tracing_log(TRACER &out, std::string_view category, int value)
+{
+  ink_assert(!"No tracing library is available");
+}
+
+inline TRACER *
+tracing_new(const char *name)
+{
+  return nullptr;
+}
+
+inline void
+tracing_delete(TRACER *tracer)
+{
+}
+#endif
+
+class Tracing
+{
+public:
+  void enable(int value = 1);
+  void disable();
+
+  bool is_enabled();
+
+  TRACER *make_tracer(const char *name);
+  void delete_tracer(TRACER *tracer);
+
+private:
+  std::atomic<int> _enabled;
+};
+
+inline bool
+Tracing::is_enabled()
+{
+  return _enabled > 0;
+}
+
+inline TRACER *
+Tracing::make_tracer(const char *name)
+{
+  return tracing_new(name);
+}
+
+inline void
+Tracing::delete_tracer(TRACER *tracer)
+{
+  tracing_delete(tracer);
+}
+
+extern std::unique_ptr<Tracing> tracing;
+
+#define TRACE_TAG(out, category, message)   \

Review comment:
       I think we should have TS API to allow plugins to leverage/add tags too. Using Tracing just within ATS core may not have much value as the Tracing is primarily meant to solve the distributed system use case (trace request as it travels through micro services).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org