From 36a2226c7ea23d1c10424272c91d6ee9126fa7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Reyrol?= Date: Mon, 8 Jan 2024 14:54:27 +0100 Subject: [PATCH] feat(packages): add tracepusher & har-to-otel --- ReadMe.md | 2 ++ src/packages/default.nix | 2 ++ src/packages/har-to-otel/default.nix | 48 ++++++++++++++++++++++++++ src/packages/har-to-otel/setup.py | 20 +++++++++++ src/packages/har-to-otel/shebang.patch | 10 ++++++ src/packages/tracepusher/default.nix | 48 ++++++++++++++++++++++++++ src/packages/tracepusher/setup.py | 20 +++++++++++ src/packages/tracepusher/shebang.patch | 10 ++++++ 8 files changed, 160 insertions(+) create mode 100644 src/packages/har-to-otel/default.nix create mode 100644 src/packages/har-to-otel/setup.py create mode 100644 src/packages/har-to-otel/shebang.patch create mode 100644 src/packages/tracepusher/default.nix create mode 100644 src/packages/tracepusher/setup.py create mode 100644 src/packages/tracepusher/shebang.patch diff --git a/ReadMe.md b/ReadMe.md index 619b01f..093464c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -12,6 +12,8 @@ - [otel-collector-builder](https://github.com/open-telemetry/opentelemetry-collector/tree/main/cmd/builder) - Generates a custom OpenTelemetry Collector binary based on a given configuration - [tracetest](https://github.com/kubeshop/tracetest) - Build integration and end-to-end tests in minutes using OpenTelemetry and trace-based testing +- [tracepusher](https://github.com/agardnerIT/tracepusher) - Generate and push OpenTelemetry Trace data to an OTEL collector in JSON format +- [har-to-otel](https://github.com/agardnerIT/tracepusher/tree/main/har-to-otel) - Chrome DevTools HAR file to OpenTelemetry converter ## Library diff --git a/src/packages/default.nix b/src/packages/default.nix index f79c97b..a09a5d5 100644 --- a/src/packages/default.nix +++ b/src/packages/default.nix @@ -7,4 +7,6 @@ prev: otel-collector-builder = prev.callPackage ./otel-collector-builder.nix { }; # Remove when merged: https://github.com/NixOS/nixpkgs/pull/275406 tracetest = prev.callPackage ./tracetest.nix { }; + tracepusher = prev.callPackage ./tracepusher { }; + har-to-otel = prev.callPackage ./har-to-otel { }; } diff --git a/src/packages/har-to-otel/default.nix b/src/packages/har-to-otel/default.nix new file mode 100644 index 0000000..aa2bdee --- /dev/null +++ b/src/packages/har-to-otel/default.nix @@ -0,0 +1,48 @@ +{ lib +, python3 +, python3Packages +, fetchFromGitHub +, substituteAll +}: + +python3Packages.buildPythonApplication rec { + pname = "har-to-otel"; + version = "0.9.0"; + format = "setuptools"; + + disabled = python3.pythonOlder "3.11"; + + src = fetchFromGitHub { + owner = "agardnerIT"; + repo = "tracepusher"; + rev = "668053739ee93556f6a121bf0f047514379c4596"; + hash = "sha256-w+xrp2uHoXZQv4YzM1Kmiv2KSlM0iHh1n8OlgUcq0OQ="; + }; + + patches = [ ./shebang.patch ]; + + postPatch = let + setup = substituteAll { + src = ./setup.py; + desc = meta.description; + inherit pname version; + }; + in '' + ln -s ${setup} setup.py + ''; + + propagatedBuildInputs = [ + python3Packages.requests + ]; + + doCheck = false; + + meta = with lib; { + changelog = "https://github.com/agardnerIT/tracepusher/releases/tag/${version}"; + description = "Chrome DevTools HAR File to OpenTelemetry Converter"; + homepage = "https://github.com/agardnerIT/tracepusher/tree/main/har-to-otel"; + license = licenses.asl20; + maintainers = with maintainers; [ gaelreyrol ]; + mainProgrom = "har-to-otel.py"; + }; +} \ No newline at end of file diff --git a/src/packages/har-to-otel/setup.py b/src/packages/har-to-otel/setup.py new file mode 100644 index 0000000..641fa04 --- /dev/null +++ b/src/packages/har-to-otel/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import codecs +import os +from setuptools import setup, find_packages + +def open_local(paths, mode="r", encoding="utf8"): + path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths) + return codecs.open(path, mode, encoding) + +with open_local(["requirements.txt"]) as req: + install_requires = req.read().split("\n") + +setup(name='@pname@', + version='@version@', + description='@desc@', + scripts=["har-to-otel/har-to-otel.py"], + packages=find_packages(), + install_requires=install_requires, +) \ No newline at end of file diff --git a/src/packages/har-to-otel/shebang.patch b/src/packages/har-to-otel/shebang.patch new file mode 100644 index 0000000..2b56dd4 --- /dev/null +++ b/src/packages/har-to-otel/shebang.patch @@ -0,0 +1,10 @@ +diff --git a/har-to-otel/har-to-otel.py b/har-to-otel/har-to-otel.py +index 135350e..658e6e5 100644 +--- a/har-to-otel/har-to-otel.py ++++ b/har-to-otel/har-to-otel.py +@@ -1,3 +1,5 @@ ++#! /usr/bin/env python ++ + import json + import math + import subprocess diff --git a/src/packages/tracepusher/default.nix b/src/packages/tracepusher/default.nix new file mode 100644 index 0000000..0ac99c0 --- /dev/null +++ b/src/packages/tracepusher/default.nix @@ -0,0 +1,48 @@ +{ lib +, python3 +, python3Packages +, fetchFromGitHub +, substituteAll +}: + +python3Packages.buildPythonApplication rec { + pname = "tracepusher"; + version = "0.9.0"; + format = "setuptools"; + + disabled = python3.pythonOlder "3.11"; + + src = fetchFromGitHub { + owner = "agardnerIT"; + repo = "tracepusher"; + rev = version; + hash = "sha256-OtdIIw6DxyTHZusuP3oJxxXJ4Ic0zoYQa805jHvh9oo="; + }; + + patches = [ ./shebang.patch ]; + + postPatch = let + setup = substituteAll { + src = ./setup.py; + desc = meta.description; + inherit pname version; + }; + in '' + ln -s ${setup} setup.py + ''; + + propagatedBuildInputs = [ + python3Packages.requests + ]; + + doCheck = false; + + meta = with lib; { + changelog = "https://github.com/agardnerIT/tracepusher/releases/tag/${version}"; + description = "Generate and push OpenTelemetry Trace data to an OTEL collector in JSON format"; + homepage = "https://github.com/agardnerIT/tracepusher"; + license = licenses.asl20; + maintainers = with maintainers; [ gaelreyrol ]; + mainProgram = "tracepusher"; + }; +} \ No newline at end of file diff --git a/src/packages/tracepusher/setup.py b/src/packages/tracepusher/setup.py new file mode 100644 index 0000000..71b1cc1 --- /dev/null +++ b/src/packages/tracepusher/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import codecs +import os +from setuptools import setup, find_packages + +def open_local(paths, mode="r", encoding="utf8"): + path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths) + return codecs.open(path, mode, encoding) + +with open_local(["requirements.txt"]) as req: + install_requires = req.read().split("\n") + +setup(name='@pname@', + version='@version@', + description='@desc@', + scripts=["tracepusher.py"], + packages=find_packages(), + install_requires=install_requires, +) \ No newline at end of file diff --git a/src/packages/tracepusher/shebang.patch b/src/packages/tracepusher/shebang.patch new file mode 100644 index 0000000..7130d8e --- /dev/null +++ b/src/packages/tracepusher/shebang.patch @@ -0,0 +1,10 @@ +diff --git a/tracepusher.py b/tracepusher.py +index c23c526..e0490b4 100644 +--- a/tracepusher.py ++++ b/tracepusher.py +@@ -1,3 +1,5 @@ ++#! /usr/bin/env python ++ + import sys + import requests + import time