"use strict";exports.__esModule=true;exports.default=void 0;var _crypto=require("crypto");var _nodeFetch=_interopRequireDefault(require("node-fetch"));var Log=_interopRequireWildcard(require("../../../build/output/log"));function _getRequireWildcardCache(){if(typeof WeakMap!=="function")return null;var cache=new WeakMap();_getRequireWildcardCache=function(){return cache;};return cache;}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache();if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}let traceId=process.env.TRACE_ID;const localEndpoint={serviceName:'nextjs',ipv4:'127.0.0.1',port:9411};const zipkinUrl=`http://${localEndpoint.ipv4}:${localEndpoint.port}`;const zipkinAPI=`${zipkinUrl}/api/v2/spans`;const reportToLocalHost=(name,duration,timestamp,id,parentId,attrs)=>{if(!traceId){traceId=process.env.TRACE_ID=(0,_crypto.randomBytes)(8).toString('hex');Log.info(`Zipkin trace will be available on ${zipkinUrl}/zipkin/traces/${traceId}`);}const body=[{traceId,parentId,name,id,timestamp,duration,localEndpoint,tags:attrs}];// We intentionally do not block on I/O here.
(0,_nodeFetch.default)(zipkinAPI,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(body)}).catch(console.log);};var _default=reportToLocalHost;exports.default=_default;
//# sourceMappingURL=to-zipkin.js.map