{"action":"created","comment":{"url":"https://api.github.com/repos/uber/jaeger-client-node/pulls/comments/82718396","pull_request_review_id":3606046,"id":82718396,"diff_hunk":"@@ -20,10 +20,185 @@\n \n import SpanContext from './span_context';\n import Span from './span';\n+import ConstSampler from './samplers/const_sampler';\n+import InMemoryReporter from './reporters/in_memory_reporter';\n+import NoopReporter from './reporters/noop_reporter';\n+import ProbabilisticSampler from './samplers/probabilistic_sampler';\n+import RatelimitingSampler from './samplers/ratelimiting_sampler';\n+import RemoteReporter from './reporters/remote_reporter';\n+import RemoteSampler from './samplers/remote_sampler';\n import Tracer from './tracer';\n+import UDPSender from './reporters/udp_sender';\n+import {Validator} from 'jsonschema';\n+\n+\n+let configSchema = {\n+    'type': 'object',\n+    'required': ['jaeger'],\n+    'properties': {\n+        'jaeger': {\n+            'type': 'object',\n+            '$ref': '/jaeger'\n+        }\n+    },\n+};\n+\n+let constSamplerSchema = {\n+    'id': '/const',\n+    'type': 'object',\n+    'properties': {\n+        'type': {'type': 'string' },\n+        'param': {'type': 'boolean' }\n+    },\n+    'required': ['type', 'param'],\n+    'additionalProperties': false\n+};\n+\n+let probabilisticSamplerSchema = {\n+    'id': '/probabilistic',\n+    'type': 'object',\n+    'properties': {\n+        'type': {'type': 'string' },\n+        'param': {'type': 'number' }\n+    },\n+    'required': ['type', 'param'],\n+    'additionalProperties': false\n+};\n+\n+let ratelimitingSamplerSchema = {\n+    'id': '/ratelimiting',\n+    'type': 'object',\n+    'properties': {\n+        'type': {'type': 'string' },\n+        'param': {'type': 'number' }\n+    },\n+    'required': ['type', 'param'],\n+    'additionalProperties': false\n+};\n+\n+let remoteSamplerSchema = {\n+    'id': '/remote',\n+    'type': 'object',\n+    'properties': {\n+        'type': {'type': 'string' },\n+        'param': {'type': 'string' },\n+        'managerHostPort': {'type': 'string'}\n+    },\n+    'required': ['type', 'param'],\n+    'additionalProperties': false\n+};\n+\n+let jaegerSchema = {\n+    'id': '/jaeger',\n+    'type': 'object',\n+    'required': ['serviceName'],\n+    'properties': {\n+        'serviceName': {'type': 'string'},\n+        'disable': {'type': 'boolean'},\n+        'sampler': {\n+            'type': 'object',\n+            // should be 'oneOf', but that doesn't work properly with this implementation.\n+            'anyOf': [\n+                {'$ref': 'const'},\n+                {'$ref': 'probabilistic'},\n+                {'$ref': 'ratelimiting'},\n+                {'$ref': 'remote'}\n+            ]\n+        },\n+        'reporter': {\n+            'properties': {\n+                'logSpans': {'type': 'boolean'},\n+                'agentHost': {'type': 'string'},\n+                'agentPort': {'type': 'number'},\n+                'flushIntervalMs': {'type': 'number'}\n+            },\n+            'additionalProperties': false\n+        }\n+    }\n+};\n+\n+let getSampler = (options) => {\n+    let type = options.sampler.type;\n+    let param = options.sampler.param;\n+\n+    let sampler;\n+    if (type === 'probabilistic') {\n+       sampler = new ProbabilisticSampler(param);\n+    }\n+\n+    if (type === 'ratelimiting') {\n+        sampler = new RatelimitingSampler(param);\n+    }\n+\n+    if (type === 'const') {\n+        sampler = new ConstSampler(param);\n+    }\n+\n+    if (type === 'remote') {\n+        sampler = new RemoteSampler(options.serviceName);\n+    }\n+\n+    return sampler;\n+}\n+\n+let initTracer = (options) => {\n+    let v = new Validator();\n+    v.addSchema(constSamplerSchema);\n+    v.addSchema(probabilisticSamplerSchema);\n+    v.addSchema(ratelimitingSamplerSchema);\n+    v.addSchema(remoteSamplerSchema);\n+    v.addSchema(jaegerSchema);\n+    v.validate(options, configSchema, {\n+        throwError: true\n+    });\n+\n+    options = options.jaeger;\n+\n+    let reporter = null;\n+    let sampler = null;\n+    if (options.disable) {\n+        reporter = new NoopReporter();\n+        sampler = new ConstSampler(false);\n+    } else {\n+        let sender;\n+        let reporterOptions = {};\n+        if (options.reporter) {\n+            if (options.reporter.logSpans) {\n+                // use logging reporter\n+            }\n+            if (options.reporter.flushIntervalMs) {\n+                reporterOptions['bufferFlushInterval'] = options.reporter.flushIntervalMs;\n+            }\n+\n+            if (options.reporter.agentHost && options.reporter.agentPort) {\n+                let hostPort = `${options.reporter.agentHost}:${options.reporter.agentPort}`;\n+                sender = new UDPSender(hostPort);\n+            } else {\n+                // use default sender\n+                sender = new UDPSender();\n+            }\n+        } else {\n+            // use default sender\n+            sender = new UDPSender();\n+        }\n+\n+\n+        reporter = new RemoteReporter(sender, reporterOptions);","path":"src/index.js","position":167,"original_position":167,"commit_id":"ecdb1857a972d3f2a6b724f40cd0fa1c42da8949","original_commit_id":"ecdb1857a972d3f2a6b724f40cd0fa1c42da8949","user":{"login":"oibe","id":1320611,"avatar_url":"https://avatars.githubusercontent.com/u/1320611?v=3","gravatar_id":"","url":"https://api.github.com/users/oibe","html_url":"https://github.com/oibe","followers_url":"https://api.github.com/users/oibe/followers","following_url":"https://api.github.com/users/oibe/following{/other_user}","gists_url":"https://api.github.com/users/oibe/gists{/gist_id}","starred_url":"https://api.github.com/users/oibe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oibe/subscriptions","organizations_url":"https://api.github.com/users/oibe/orgs","repos_url":"https://api.github.com/users/oibe/repos","events_url":"https://api.github.com/users/oibe/events{/privacy}","received_events_url":"https://api.github.com/users/oibe/received_events","type":"User","site_admin":false},"body":"but options.reporter is a config section not a reporter.  Do you mean if \"options.reporter.reporterImpl\" is defined?","created_at":"2016-10-11T03:10:10Z","updated_at":"2016-10-11T03:10:10Z","html_url":"https://github.com/uber/jaeger-client-node/pull/27#discussion_r82718396","pull_request_url":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27","_links":{"self":{"href":"https://api.github.com/repos/uber/jaeger-client-node/pulls/comments/82718396"},"html":{"href":"https://github.com/uber/jaeger-client-node/pull/27#discussion_r82718396"},"pull_request":{"href":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27","id":88714276,"html_url":"https://github.com/uber/jaeger-client-node/pull/27","diff_url":"https://github.com/uber/jaeger-client-node/pull/27.diff","patch_url":"https://github.com/uber/jaeger-client-node/pull/27.patch","issue_url":"https://api.github.com/repos/uber/jaeger-client-node/issues/27","number":27,"state":"open","locked":false,"title":"Yaml config loading for Jaeger Tracer","user":{"login":"oibe","id":1320611,"avatar_url":"https://avatars.githubusercontent.com/u/1320611?v=3","gravatar_id":"","url":"https://api.github.com/users/oibe","html_url":"https://github.com/oibe","followers_url":"https://api.github.com/users/oibe/followers","following_url":"https://api.github.com/users/oibe/following{/other_user}","gists_url":"https://api.github.com/users/oibe/gists{/gist_id}","starred_url":"https://api.github.com/users/oibe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oibe/subscriptions","organizations_url":"https://api.github.com/users/oibe/orgs","repos_url":"https://api.github.com/users/oibe/repos","events_url":"https://api.github.com/users/oibe/events{/privacy}","received_events_url":"https://api.github.com/users/oibe/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-10T19:05:09Z","updated_at":"2016-10-11T03:10:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b7836a72e2bcdc5320e98c527a1ee6898b2f4c7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27/commits","review_comments_url":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27/comments","review_comment_url":"https://api.github.com/repos/uber/jaeger-client-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uber/jaeger-client-node/issues/27/comments","statuses_url":"https://api.github.com/repos/uber/jaeger-client-node/statuses/ecdb1857a972d3f2a6b724f40cd0fa1c42da8949","head":{"label":"uber:create_yaml_parsing","ref":"create_yaml_parsing","sha":"ecdb1857a972d3f2a6b724f40cd0fa1c42da8949","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":56551035,"name":"jaeger-client-node","full_name":"uber/jaeger-client-node","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/jaeger-client-node","description":"Jaeger Bindings for Javascript OpenTracing API","fork":false,"url":"https://api.github.com/repos/uber/jaeger-client-node","forks_url":"https://api.github.com/repos/uber/jaeger-client-node/forks","keys_url":"https://api.github.com/repos/uber/jaeger-client-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/jaeger-client-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/jaeger-client-node/teams","hooks_url":"https://api.github.com/repos/uber/jaeger-client-node/hooks","issue_events_url":"https://api.github.com/repos/uber/jaeger-client-node/issues/events{/number}","events_url":"https://api.github.com/repos/uber/jaeger-client-node/events","assignees_url":"https://api.github.com/repos/uber/jaeger-client-node/assignees{/user}","branches_url":"https://api.github.com/repos/uber/jaeger-client-node/branches{/branch}","tags_url":"https://api.github.com/repos/uber/jaeger-client-node/tags","blobs_url":"https://api.github.com/repos/uber/jaeger-client-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/jaeger-client-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/jaeger-client-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/jaeger-client-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/jaeger-client-node/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/jaeger-client-node/languages","stargazers_url":"https://api.github.com/repos/uber/jaeger-client-node/stargazers","contributors_url":"https://api.github.com/repos/uber/jaeger-client-node/contributors","subscribers_url":"https://api.github.com/repos/uber/jaeger-client-node/subscribers","subscription_url":"https://api.github.com/repos/uber/jaeger-client-node/subscription","commits_url":"https://api.github.com/repos/uber/jaeger-client-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/jaeger-client-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/jaeger-client-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/jaeger-client-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/jaeger-client-node/contents/{+path}","compare_url":"https://api.github.com/repos/uber/jaeger-client-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/jaeger-client-node/merges","archive_url":"https://api.github.com/repos/uber/jaeger-client-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/jaeger-client-node/downloads","issues_url":"https://api.github.com/repos/uber/jaeger-client-node/issues{/number}","pulls_url":"https://api.github.com/repos/uber/jaeger-client-node/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/jaeger-client-node/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/jaeger-client-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/jaeger-client-node/labels{/name}","releases_url":"https://api.github.com/repos/uber/jaeger-client-node/releases{/id}","deployments_url":"https://api.github.com/repos/uber/jaeger-client-node/deployments","created_at":"2016-04-19T00:11:04Z","updated_at":"2016-09-30T09:31:12Z","pushed_at":"2016-10-11T00:04:06Z","git_url":"git://github.com/uber/jaeger-client-node.git","ssh_url":"git@github.com:uber/jaeger-client-node.git","clone_url":"https://github.com/uber/jaeger-client-node.git","svn_url":"https://github.com/uber/jaeger-client-node","homepage":"","size":205,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":2,"default_branch":"master"}},"base":{"label":"uber:master","ref":"master","sha":"b2165341a212bbf1a6b4f72e14596e260938f318","user":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"repo":{"id":56551035,"name":"jaeger-client-node","full_name":"uber/jaeger-client-node","owner":{"login":"uber","id":538264,"avatar_url":"https://avatars.githubusercontent.com/u/538264?v=3","gravatar_id":"","url":"https://api.github.com/users/uber","html_url":"https://github.com/uber","followers_url":"https://api.github.com/users/uber/followers","following_url":"https://api.github.com/users/uber/following{/other_user}","gists_url":"https://api.github.com/users/uber/gists{/gist_id}","starred_url":"https://api.github.com/users/uber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uber/subscriptions","organizations_url":"https://api.github.com/users/uber/orgs","repos_url":"https://api.github.com/users/uber/repos","events_url":"https://api.github.com/users/uber/events{/privacy}","received_events_url":"https://api.github.com/users/uber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uber/jaeger-client-node","description":"Jaeger Bindings for Javascript OpenTracing API","fork":false,"url":"https://api.github.com/repos/uber/jaeger-client-node","forks_url":"https://api.github.com/repos/uber/jaeger-client-node/forks","keys_url":"https://api.github.com/repos/uber/jaeger-client-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uber/jaeger-client-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uber/jaeger-client-node/teams","hooks_url":"https://api.github.com/repos/uber/jaeger-client-node/hooks","issue_events_url":"https://api.github.com/repos/uber/jaeger-client-node/issues/events{/number}","events_url":"https://api.github.com/repos/uber/jaeger-client-node/events","assignees_url":"https://api.github.com/repos/uber/jaeger-client-node/assignees{/user}","branches_url":"https://api.github.com/repos/uber/jaeger-client-node/branches{/branch}","tags_url":"https://api.github.com/repos/uber/jaeger-client-node/tags","blobs_url":"https://api.github.com/repos/uber/jaeger-client-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uber/jaeger-client-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uber/jaeger-client-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/uber/jaeger-client-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uber/jaeger-client-node/statuses/{sha}","languages_url":"https://api.github.com/repos/uber/jaeger-client-node/languages","stargazers_url":"https://api.github.com/repos/uber/jaeger-client-node/stargazers","contributors_url":"https://api.github.com/repos/uber/jaeger-client-node/contributors","subscribers_url":"https://api.github.com/repos/uber/jaeger-client-node/subscribers","subscription_url":"https://api.github.com/repos/uber/jaeger-client-node/subscription","commits_url":"https://api.github.com/repos/uber/jaeger-client-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/uber/jaeger-client-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/uber/jaeger-client-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/uber/jaeger-client-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/uber/jaeger-client-node/contents/{+path}","compare_url":"https://api.github.com/repos/uber/jaeger-client-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uber/jaeger-client-node/merges","archive_url":"https://api.github.com/repos/uber/jaeger-client-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uber/jaeger-client-node/downloads","issues_url":"https://api.github.com/repos/uber/jaeger-client-node/issues{/number}","pulls_url":"https://api.github.com/repos/uber/jaeger-client-node/pulls{/number}","milestones_url":"https://api.github.com/repos/uber/jaeger-client-node/milestones{/number}","notifications_url":"https://api.github.com/repos/uber/jaeger-client-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uber/jaeger-client-node/labels{/name}","releases_url":"https://api.github.com/repos/uber/jaeger-client-node/releases{/id}","deployments_url":"https://api.github.com/repos/uber/jaeger-client-node/deployments","created_at":"2016-04-19T00:11:04Z","updated_at":"2016-09-30T09:31:12Z","pushed_at":"2016-10-11T00:04:06Z","git_url":"git://github.com/uber/jaeger-client-node.git","ssh_url":"git@github.com:uber/jaeger-client-node.git","clone_url":"https://github.com/uber/jaeger-client-node.git","svn_url":"https://github.com/uber/jaeger-client-node","homepage":"","size":205,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27"},"html":{"href":"https://github.com/uber/jaeger-client-node/pull/27"},"issue":{"href":"https://api.github.com/repos/uber/jaeger-client-node/issues/27"},"comments":{"href":"https://api.github.com/repos/uber/jaeger-client-node/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/uber/jaeger-client-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uber/jaeger-client-node/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/uber/jaeger-client-node/statuses/ecdb1857a972d3f2a6b724f40cd0fa1c42da8949"}}}}
{"actor":{"display_login":"oibe"}}